<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">

  <title>ignore</title>
  <link href="../cppreference.css" rel="stylesheet" type="text/css">
</head>

<body>
<table>
  <tr>
  <td>
  <div class="body-content">

  <div class="header-box">
    <a href="../index.html">cppreference.com</a> &gt; <a href=
    "index.html">C++ I/O</a> &gt; <a href="ignore.html">ignore</a>
  </div>

  <div class="name-format">
    ignore
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;fstream&gt;
  istream&amp; ignore( streamsize num=1, int delim=<strong>EOF</strong> );
</pre>

  <p>The ignore() function is used with input streams. It reads and
  throws away characters until <em>num</em> characters have been read
  (where <em>num</em> defaults to 1) or until the character
  <em>delim</em> is read (where <em>delim</em> defaults to
  <strong>EOF</strong>).</p>

  <p>The ignore() function can sometimes be useful when using the
  getline() function together with the &gt;&gt; operator.  For
  example, if you read some input that is followed by a newline using
  the &gt;&gt; operator, the newline will remain in the input as the
  next thing to be read.  Since getline() will by default stop reading
  input when it reaches a newline, a subsequent call to getline() will
  return an empty string.  In this case, the ignore() function could
  be called before getline() to "throw away" the newline.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="get.html">get</a><br>
    <a href="getline.html">getline</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
